<!--
 * @Author: TANGB02 13233582+Ace-Tang@user.noreply.gitee.com
 * @Date: 2024-03-05 09:18:02
 * @LastEditors: TANGB02 13233582+Ace-Tang@user.noreply.gitee.com
 * @LastEditTime: 2024-03-11 10:30:00
 * @FilePath: \ycq\ycq1.0\src\pages\animalDetails\animaldetails.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="anidetails">
    <div class="head">
      <!-- 面包屑 -->
      <a-breadcrumb style="margin: 16px" separator=">">
        <a-breadcrumb-item
          v-for="(item, index) in $route.matched"
          :key="index"
          :to="{ path: item.path }"
          style="cursor: pointer"
        >
          {{ item.meta.title }}
        </a-breadcrumb-item>
      </a-breadcrumb>
    </div>
    <div class="details">
      <div class="headerImg">
        <img
          :src="`http://i79768a535.zicp.fun:23570/common/download?name=${imgName}`"
          alt=""
        />
      </div>
      <div class="msg">
        <!-- 信息列表 -->
        <div class="list">
          <!-- 行 -->
          <div class="rows">
            <div class="row-name">我的名字:</div>
            <div class="rows-cnt">
              {{ formData.animalName }}
            </div>
          </div>
          <div class="rows">
            <div class="row-name">
              年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;龄:
            </div>
            <div class="rows-cnt">{{ formData.animalAge }}年</div>
          </div>
          <div class="rows">
            <div class="row-name">
              品&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;种:
            </div>
            <div class="rows-cnt">{{ formData.breed }}</div>
          </div>
        </div>
        <div class="adoptBtn" @click="handleAdopt">我要领养</div>
        <div class="review" @click="toreview">去评论></div>
      </div>
    </div>
    <div class="anotherdetials">
      <div class="title">
        <span>详细信息</span>
      </div>
      <div class="petDetail-cnt">
        <span>{{ formData.animalDetails }}</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
import { getAnimalById, download } from "@/service/api.js";
const router = useRouter();
const formData = ref({
  animalName: "",
  animalAge: 0,
  breed: "",
  animalDetails: "",
});
const imgName = ref("");
const load = async (name) => {
  await download({ name });
};
const animalNumber = ref(
  parseInt(router.currentRoute._value.query.animalNumbers)
);
console.log(animalNumber.value);

const animalById = async () => {
  const res = await getAnimalById({ animalNumber: animalNumber.value });
  console.log(res);
  formData.value = res.data;
  imgName.value = res.data.animalImage;
};
animalById(imgName.value);
load();
const handleAdopt = () => {
  router.push({
    name: "addApplication",
    query: { animalNumbers: router.currentRoute._value.query.animalNumbers },
  });
};

//评论
const toreview = () => {
  router.push({
    name: "animalReview",
    query: { animalNumber: animalNumber.value },
  });
};
</script>
<style scoped>
.anidetails {
  display: flex;
  flex-flow: column nowrap;
  justify-content: space-between;
  width: 1000px;
  height: 570px;
  /* background-color: red; */
  .head {
    width: 1000px;
    height: 40px;
  }
  .details {
    display: flex;
    justify-content: space-between;
    flex-flow: row nowrap;
    width: 1000px;
    height: 100%;
    .headerImg {
      display: flex;
      justify-content: space-between;
      flex-flow: column nowrap;
      align-items: center;
      width: 460px;
      height: 400px;
      img {
        width: 400px;
        height: 300px;
        margin-top: 30px;
      }
    }
    .msg {
      margin-top: 30px;
      width: 500px;
      height: 300px;
      .review {
        cursor: default;
        display: inline-block;
        margin-left: 20px;
        font-size: 14px;
        color: #988983;
      }

      .adoptBtn {
        margin-top: 30px;
        display: inline-block;
        font-size: 22px;
        color: #fff;
        background: #e98f3e;
        text-align: center;
        width: 208px;
        height: 53px;
        line-height: 53px;
        border-radius: 27px;
        border: 1px solid #dd873a;
      }
      .list {
        border-bottom: 1px dotted #cbc6c1;

        .rows {
          overflow: hidden;
          padding-bottom: 28px;
          font-size: 16px;
        }
        .row-name {
          float: left;
          width: 80px;
          color: #988983;
        }
        .rows-cnt {
          float: left;
          width: 80px;
          color: #988983;
        }
      }
    }
  }
  .anotherdetials {
    width: 1000px;
    height: 130px;
    .title {
      height: 45px;
      line-height: 45px;
      border-bottom: 1px solid #d4d0cd;
      font-size: 20px;
      color: #423834;
      position: relative;
      span {
        position: absolute;
        left: 0;
        bottom: -2px;
        border-bottom: 3px solid #665843;
      }
      .petDetail-cnt {
        padding: 25px 0;
        border-top: 1px solid #fbf6f1;
      }
    }
  }
}
</style>
